package com.itheima.demo02;

import java.io.*;

//字节缓冲流一次读取一个数组复制
public class ByteClass02 {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        BufferedInputStream du = null;
        BufferedOutputStream xie = null;
        try{
            du = new BufferedInputStream(new FileInputStream("F:\\study\\就业班\\4.jpg"));
            xie = new BufferedOutputStream(new FileOutputStream("F:\\study\\卡卡西.jpg"));
            byte[] bytes = new byte[1024];
            int len;
            while ((len = du.read(bytes)) != -1){
                xie.write(bytes,0,len);
            }
        }catch (IOException e){
            e.getMessage();
        }finally {
            if (du != null) {
                try {
                    du.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (xie != null) {
                try {
                    xie.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println("程序运行了" + (end - start) + "毫秒！");
    }
}
